<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>闵行区</title>
	<%@include file="/common/wxCommon.jspf"%>
	<link rel="stylesheet" href="${ctx }/css/org.css">
<style type="text/css">
.w100 {
	width: 100%!important;
}
.mp0 {
  margin-left: 0px;
  padding-left: 0px;
}
.weui_label {
	width: 6em;
	text-align: justify;
}
</style>
</head>
<body class="reg">
	<div class="weui_tab">
		<div class="weui_navbar">
			<a href="#organ-reg" class="weui_navbar_item weui_bar_item_on">机构注册 </a>
			<a href="#code-reg" class="weui_navbar_item"> 邀请码注册 </a>
		</div>
		<div class="weui_tab_bd">
			<div id="organ-reg" class="weui_tab_bd_item weui_tab_bd_item_active">
				<form method="post" action="${ctx }/weixin/organ/regist/organRegister.shtml" id="organRegForm" onsubmit="">
				<input type="hidden" name="orgInfoFormMap.province" value="">
				<input type="hidden" name="orgInfoFormMap.city" value="">
				<input type="hidden" name="orgInfoFormMap.area" value="">
				<input type="hidden" name="orgInfoFormMap.street" value="">
					<div class="weui_cells weui_cells_form">
						<div class="weui_cell">
							<div class="weui_cell_hd ">
								<label class="weui_label"><span class="required">*</span>机构名称</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入机构名称" name="orgInfoFormMap.orgName">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>机构代码</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入组织结构代码" name="orgInfoFormMap.orgCode">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>法人代表</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入法人代表" name="orgInfoFormMap.owner">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>注册时间</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="orgInfoFormMap_regDate" placeholder="请输入注册时间" name="orgInfoFormMap.regDate">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
					        <div class="weui_cell_hd"><label class="weui_label">&nbsp;&thinsp;机构性质</label></div>
					        <div class="weui_cell_bd weui_cell_primary">
					          <input class="weui_input" id="selectOrgType" name="selectOrgType" type="text" value="" readonly="" placeholder="请选择机构性质">
					          <input class="weui_input hide" id="orgInfoFormMap_otherType" name="orgInfoFormMap.otherType" type="text" placeholder="请输入机构性质">
					          <input name="orgInfoFormMap.orgType" id="orgInfoFormMap_orgType" type="hidden" value="">
					        </div>
					        <div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
					    </div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>注册地址</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<div class="weui_cell mp0" id="reg_addr"></div>
								<input type="text" class="weui_input" id="orgInfoFormMap_address" placeholder="请完善注册地址" name="orgInfoFormMap.address">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>通讯地址</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="orgInfoFormMap_contactAddress" placeholder="请输入完整通讯地址" name="orgInfoFormMap.contactAddress">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label w100"><span class="required">*</span>主要服务方向</label>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_bd weui_cell_primary">
								<textarea class="weui_textarea" placeholder="请自行填写服务方向关键词" maxlength="100" rows="5"
										 name="orgInfoFormMap.otherService"></textarea>
								<div class="weui_textarea_counter"><span>0</span>/100</div>
							</div>
						</div>
						
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label">机构公众号</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" placeholder="如有，请填写" name="orgInfoFormMap.orgWeixin">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>联&nbsp;&nbsp;系&nbsp;&nbsp;人</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入联系人" name="orgInfoFormMap.contact">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>联系方式</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入联系方式" name="orgInfoFormMap.phone">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label">&nbsp;&thinsp;电子邮件</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入电子邮件" name="orgInfoFormMap.email">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>管理账号</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入管理端用户名" name="userFormMap.accountName">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>管理密码</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="password" class="weui_input" id="userFormMap_password" placeholder="请输入管理端密码" name="userFormMap.password">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>确认密码</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="password" class="weui_input" id="userFormMap_passwordConfirm" placeholder="请确认管理端密码" name="userFormMap.passwordConfirm">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
					</div>
					
					<div class="content-padded">
						<button type="submit" class="weui_btn weui_btn_warn">提交申请</button>
					</div>
				</form>
			</div>
			<div id="code-reg" class="weui_tab_bd_item">
				<form action="${ctx }/weixin/organ/regist/codeRegister.shtml" method="post" id="codeRegForm">
					<div class="weui_cells weui_cells_form">
						
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>邀请码</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入邀请码,区分大小写" name="codeFormMap.code">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>管理账号</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="text" class="weui_input" id="" placeholder="请输入管理端用户名" name="userFormMap.accountName">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>管理密码</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="password" class="weui_input" id="code_userFormMap_password" placeholder="请输入管理端密码" name="userFormMap.password">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="required">*</span>确认密码</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<input type="password" class="weui_input" id="code_userFormMap_passwordConfirm" placeholder="请确认管理端密码" name="userFormMap.passwordConfirm">
							</div>
							<div class="weui_cell_ft ">
								<i class="weui_icon_warn"></i>
							</div>
						</div>
					</div>
					<div class="content-padded">
						<button type="submit" class="weui_btn weui_btn_warn">提交申请</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<!-- start 地址选择层 -->
	<div id="addrChoosePopup" class="weui-popup-container">
	  <div class="weui-popup-modal">
	 	  <div class="weui_cells_title">请选择机构所属区域</div>
		  <div class="weui_cells weui_cells_form">
		    	<div class="weui_cell weui_cell_select">
					<div class="weui_cell_bd weui_cell_primary">
						<select class="weui_select" name="orgInfoFormMap.province">
							<option selected="" value="0">注册地址<span class="required">*</span>:省</option>
						</select>
					</div>
					<!-- <div class="weui_cell_ft ">
						<i class="weui_icon_warn"></i>
					</div> -->
				</div>
				<div class="weui_cell weui_cell_select">
					<div class="weui_cell_bd weui_cell_primary">
						<select class="weui_select" name="orgInfoFormMap.city">
							<option selected="" value="0">注册地址: 市</option>
						</select>
					</div>
					<div class="weui_cell_ft ">
						<i class="weui_icon_warn"></i>
					</div>
				</div>
				<div class="weui_cell weui_cell_select">
					<div class="weui_cell_bd weui_cell_primary">
						<select class="weui_select" name="orgInfoFormMap.area" id="orgInfoFormMap_area">
							<option selected="" value="0">注册地址: 区</option>
						</select>
					</div>
					<div class="weui_cell_ft ">
						<i class="weui_icon_warn"></i>
					</div>
				</div>
				<div class="weui_cell weui_cell_select">
					<div class="weui_cell_bd weui_cell_primary">
						<select class="weui_select" name="orgInfoFormMap.street">
							<option selected="" value="0">注册地址<span class="required">*</span>: 街道</option>
						</select>
					</div>
					<div class="weui_cell_ft ">
						<i class="weui_icon_warn"></i>
					</div>
				</div>
				<div class="content-padded">
			    <a href="javascript:closeAddrChoosePopup();" class="weui_btn weui_btn_primary" >下一步</a>
			    </div>
		  </div>
	  </div>
	</div>
	<!-- 地址选择层  end-->
	<script type="text/javascript">
		function closeAddrChoosePopup(){
			$("input[name='orgInfoFormMap.province']").val($("select[name='orgInfoFormMap.province']").val());
			$("input[name='orgInfoFormMap.city']").val($("select[name='orgInfoFormMap.city']").val());
			$("input[name='orgInfoFormMap.area']").val($("select[name='orgInfoFormMap.area']").val());
			$("input[name='orgInfoFormMap.street']").val($("select[name='orgInfoFormMap.street']").val());
			var txt = $("select[name='orgInfoFormMap.province'] option:selected").text();
			txt += " " + $("select[name='orgInfoFormMap.city'] option:selected").text();
			txt += " " + $("select[name='orgInfoFormMap.area'] option:selected").text();
			txt += " " + $("select[name='orgInfoFormMap.street'] option:selected").text();
			$("#reg_addr").html(txt);
			$.closePopup();
		}
		
		$(function() {
			$("#addrChoosePopup").popup();
			// ----------------- 初始化 注册日期
			$("#orgInfoFormMap_regDate").calendar({
				value: [(new Date().format("yyyy-MM-dd"))],
				onChange : function(p) {
					$("#organRegForm").validate().element("#orgInfoFormMap_regDate");
				}
			});
			//------------------主要服务方向文字统计
			$("[name='orgInfoFormMap.otherService']").keyup(
				function() {
					$(this).parent().find(".weui_textarea_counter").find(
							"span:first").html($(this).val().length);
			});
			//-------------------- 初始化省市区
			initRegionFormControl("310000","310100","310112","");
			// ----------------- 初始化 机构服务方向联动
			$("#orgInfoFormMap_area").change(function(){
				$("title").html($(this).find("option:selected").text());
			});
			//jquery form验证
			$("#organRegForm").validate(
					{
						submitHandler : function(form) {
							$("button[type=submit]").attr("disabled", true);
							$("button[type=submit]").addClass("weui_btn_disabled");
							form.submit();
						},
						success : function(error, element) {
							//验证通过时
							$(element).parents(".weui_cell").removeClass(
									"weui_cell_warn");
						},
						errorPlacement : function(error, element) {
							//验证失败时
							$(element).parents(".weui_cell").addClass(
									"weui_cell_warn");
						},
						rules : {
							"orgInfoFormMap.orgName" : {
								required : true
							},
							"orgInfoFormMap.orgCode" : {
								required : true
							},
							"orgInfoFormMap.owner" : {
								required : true
							},
							"orgInfoFormMap.province" : {
								required : true
							},
							"orgInfoFormMap.city" : {
								required : true
							},
							"orgInfoFormMap.area" : {
								required : true
							},
							"orgInfoFormMap.street" : {
								required : true
							},
							"orgInfoFormMap.address" : {
								required : true
							},
							"orgInfoFormMap.regDate" : {
								required : true
							},
							"orgInfoFormMap.otherService" : {
								required : true,
								maxlength : 100
							},
							"orgInfoFormMap.contact" : {
								required : true
							},
							"orgInfoFormMap.phone" : {
								required : true
							},
							"userFormMap.accountName" : {
								required : true
							},
							"userFormMap.password" : {
								required : true
							},
							"userFormMap.passwordConfirm" : {
								required : true,
								equalTo : "#userFormMap_password"
							},
							"orgInfoFormMap.email" : {
								required : false,
								email : true
							}
						}
					});
			//邀请注册
			$("#codeRegForm").validate(
					{
						submitHandler : function(form) {
							$("button[type=submit]").attr("disabled", true);
							$("button[type=submit]").addClass("weui_btn_disabled");
							form.submit();
						},
						success : function(error, element) {
							//验证通过时
							$(element).parents(".weui_cell").removeClass("weui_cell_warn");
						},
						errorPlacement : function(error, element) {
							//验证失败时
							$(element).parents(".weui_cell").addClass("weui_cell_warn");
						},
						rules : {
							"codeFormMap.code" : {
								required : true
							},
							"userFormMap.accountName" : {
								required : true
							},
							"userFormMap.password" : {
								required : true
							},
							"userFormMap.passwordConfirm" : {
								required : true,
								equalTo : "#code_userFormMap_password"
							}
						}
					});
			
			$("#selectOrgType").select({
		        title: "机构性质",
		        items: [
		          <c:forEach items="${orgTypeList }" var="record">
			      	{title : "${record.label }", value : "${record.value }"},
			      </c:forEach>
		        ],
		        onChange: function(d) {
		            $("#orgInfoFormMap_orgType").val(d.values);
		            if (d.values == 4) {
		            	$("#orgInfoFormMap_otherType").show();
		            } else {
		            	$("#orgInfoFormMap_otherType").val("");
		            	$("#orgInfoFormMap_otherType").hide();
		            }
		        }
		    });
		});
	</script>
</body>
</html>
